home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PORTABLE.ZIP / DOUPDATE.C < prev    next >
Text File  |  1992-11-21  |  4KB  |  109 lines

  1. #define        CURSES_LIBRARY  1
  2. #include <curses.h>
  3. #undef doupdate
  4.  
  5. #ifndef        NDEBUG
  6. char *rcsid_doupdate = "$Header: c:/curses/portable/RCS/doupdate.c%v 2.0 1992/11/15 03:28:50 MH Rel $";
  7. #endif
  8.  
  9. WINDOW *twin;                  /* used by many routines */
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   doupdate()   - do effiecient refresh
  15.  
  16.   X/Open Description: (part of the wnoutrefresh() description.)
  17.        These two routines allow multiple updates with more efficiency
  18.        than wrefresh() alone.  In addition to all of the window
  19.        structures representing the terminal screen: a physical screen,
  20.        describing what is actually on the screen and a virtual screen,
  21.        describing what the programmer wants to have on  the screen.
  22.  
  23.        The wrefresh() function works by first calling wnoutrefresh(),
  24.        which copies the named window to the virtual screen.  It then
  25.        calls doupdate(), which compares the virtual screen to the
  26.        physical screen and does the actual update.  If the programmer
  27.        wishes to output several windows at once, a series of cals to
  28.        wrefresh() will result in alternating calls to wnoutrefresh()
  29.        and doupdate(), causing several bursts of output to the
  30.        screen.  By first calling wnoutrefresh() for each window, it
  31.        is then possible to call doupdate() once.  This results in
  32.        only one burst of output, with probably fewer total characters
  33.        transmitted and certainly less CPU time used.
  34.  
  35.   PDCurses Description:
  36.        In addition to the above, if REGISTERWINDOWS is TRUE when the
  37.        library was compiled, any windows registered (true by default
  38.        with PDCurses and _cursvar.refreshall is TRUE, then all
  39.        registered windows will be called via wnoutrefresh() before
  40.        the actual screen update begins.
  41.  
  42.   X/Open Return Value:
  43.        The doupdate() function returns OK on success and ERR on error.
  44.  
  45.   X/Open Errors:
  46.        No errors are defined for this function.
  47.  
  48.   Portability:
  49.        PDCurses        int doupdate( void );
  50.        X/Open Dec '88  int doupdate( void );
  51.        BSD Curses      int doupdate( void );
  52.        SYS V Curses    int doupdate( void );
  53.  
  54. **man-end**********************************************************************/
  55.  
  56. int    doupdate(void)
  57. {
  58. register int   i;
  59. #ifdef REGISTERWINDOWS
  60.        WINDS*  next = _cursvar.visible;
  61.  
  62.        if (_cursvar.refreshall)
  63.        {
  64.                while (next != NULL)
  65.                {
  66.                        if (next->w->_parent != NULL)
  67.                        {
  68.                                touchwin(next->w->_parent);
  69.                                wnoutrefresh(next->w->_parent);
  70.                        }
  71.                        touchwin(next->w);
  72.                        wnoutrefresh(next->w);
  73.                        next = next->next;
  74.                }
  75.        }
  76. #endif
  77.        if  (_cursvar.shell)
  78.                reset_prog_mode();
  79.  
  80.        twin = tmpwin;
  81.        if (twin == (WINDOW *)NULL)
  82.                return( ERR );
  83.  
  84.        if (curscr->_clear)
  85.        {
  86.                PDC_clr_update(curscr);
  87.        }
  88.        else
  89.        {
  90.                if (twin->_clear)
  91.                {
  92.                        PDC_clr_update(twin);
  93.                }
  94.                else
  95.                {
  96.                        for (i = 0; i < LINES; i++)
  97.                        {
  98.                                if (twin->_firstch[i] != _NO_CHANGE)
  99.                                        if (PDC_transform_line(i))
  100.                                                break;
  101.                        }
  102.                }
  103.        }
  104.        curscr->_curx = twin->_curx;
  105.        curscr->_cury = twin->_cury;
  106.        PDC_gotoxy(curscr->_cury, curscr->_curx);
  107.        return( OK );
  108. }
  109.